import java.util.ArrayList;
import java.util.Scanner;

/*
    递增三元组
 */
public class test23 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0 ; i < n ; i++){
            a[i] = sc.nextInt();
        }

        int i=0,j=0,k=0;
        ArrayList<Integer> ans = new ArrayList<>();
        for (i = 0 ; i < n-2 ; i++){
            for (j=i+1 ; j< n-1 ; j++){
                if(a[i]<a[j])
                    for (k=j+1; k<n;k++){
                        if(!ans.contains(j))
                            ans.add(j);
                        break;
                    }

            }
        }
        System.out.println(ans.size());
    }
}
